package com.qm.struts.friendspace;

import java.util.List;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.qm.hibernate.Tblog;
import com.qm.hibernate.TblogDAO;
import com.qm.hibernate.TblogcommentDAO;

public class HisJournalAction implements Action {

	private Integer id;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		ActionContext ctx = ActionContext.getContext();		
		Integer tempId = getId();

		if (tempId != null)
			ctx.getSession().put("blogId", tempId);
		else tempId = (Integer) ctx.getSession().get("blogId");

		TblogDAO t = new TblogDAO();		
		TblogcommentDAO c = new TblogcommentDAO();
		
		Tblog list1 = t.findById(tempId);	
		List list2 = (List)c.findByBlogId(tempId);
		
		ctx.getSession().put("hisJournal", list1);
		ctx.getSession().put("blogComments", list2);
	
		return SUCCESS;
		
	}

}
